package main.java.indi.zyj.coderecord;

import main.java.indi.zyj.hot100.base.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class BinaryTreePaths {


    List<String> res = new ArrayList<>();
    public List<String> binaryTreePaths(TreeNode root) {
        getPaths(root, "");
        return res;
    }

    private void getPaths(TreeNode root, String s) {
        if (root == null) {
            return;
        }
        if (root.left == null && root.right == null) {
            res.add(new StringBuilder(s).append(root.val).toString());
        }
        s = new StringBuilder(s).append("->").toString();
        getPaths(root.left, s);
        getPaths(root.right, s);
    }

}
